<?php


abstract class BaseCpHotRbtPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'cp_hot_rbt';

	
	const CLASS_DEFAULT = 'lib.model.CpHotRbt';

	
	const NUM_COLUMNS = 32;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'cp_hot_rbt.ID';

	
	const CP_ID = 'cp_hot_rbt.CP_ID';

	
	const CP_CODE = 'cp_hot_rbt.CP_CODE';

	
	const CP_NAME = 'cp_hot_rbt.CP_NAME';

	
	const CHECK_TIME = 'cp_hot_rbt.CHECK_TIME';

	
	const CONTENT_LANGUAGE = 'cp_hot_rbt.CONTENT_LANGUAGE';

	
	const RBT_INDEX = 'cp_hot_rbt.RBT_INDEX';

	
	const LANGUAGE = 'cp_hot_rbt.LANGUAGE';

	
	const MUSIC_ID = 'cp_hot_rbt.MUSIC_ID';

	
	const ORDER_TIMES = 'cp_hot_rbt.ORDER_TIMES';

	
	const PRICE = 'cp_hot_rbt.PRICE';

	
	const PRICE_GROUP_ID = 'cp_hot_rbt.PRICE_GROUP_ID';

	
	const RELATIVE_TIME = 'cp_hot_rbt.RELATIVE_TIME';

	
	const SET_TIMES = 'cp_hot_rbt.SET_TIMES';

	
	const SINGER_NAME = 'cp_hot_rbt.SINGER_NAME';

	
	const SINGER_NAME_LETTER = 'cp_hot_rbt.SINGER_NAME_LETTER';

	
	const SINGER_SEX = 'cp_hot_rbt.SINGER_SEX';

	
	const STATUS = 'cp_hot_rbt.STATUS';

	
	const TABLE_TYPE = 'cp_hot_rbt.TABLE_TYPE';

	
	const TONE_ADDRESS = 'cp_hot_rbt.TONE_ADDRESS';

	
	const TONE_CODE = 'cp_hot_rbt.TONE_CODE';

	
	const TONE_CODE_LONG = 'cp_hot_rbt.TONE_CODE_LONG';

	
	const TONE_ID = 'cp_hot_rbt.TONE_ID';

	
	const TONE_NAME = 'cp_hot_rbt.TONE_NAME';

	
	const TONE_NAME_LETTER = 'cp_hot_rbt.TONE_NAME_LETTER';

	
	const TONE_PATH = 'cp_hot_rbt.TONE_PATH';

	
	const TONE_PRE_LISTEN_ADDRESS = 'cp_hot_rbt.TONE_PRE_LISTEN_ADDRESS';

	
	const TONE_PRE_LISTEN_PATH = 'cp_hot_rbt.TONE_PRE_LISTEN_PATH';

	
	const TONE_VALID_DAY = 'cp_hot_rbt.TONE_VALID_DAY';

	
	const UPDATE_TIME = 'cp_hot_rbt.UPDATE_TIME';

	
	const UPLOAD_TIME = 'cp_hot_rbt.UPLOAD_TIME';

	
	const UPLOAD_TYPE = 'cp_hot_rbt.UPLOAD_TYPE';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'CpId', 'CpCode', 'CpName', 'CheckTime', 'ContentLanguage', 'RbtIndex', 'Language', 'MusicId', 'OrderTimes', 'Price', 'PriceGroupId', 'RelativeTime', 'SetTimes', 'SingerName', 'SingerNameLetter', 'SingerSex', 'Status', 'TableType', 'ToneAddress', 'ToneCode', 'ToneCodeLong', 'ToneId', 'ToneName', 'ToneNameLetter', 'TonePath', 'TonePreListenAddress', 'TonePreListenPath', 'ToneValidDay', 'UpdateTime', 'UploadTime', 'UploadType', ),
		BasePeer::TYPE_COLNAME => array (CpHotRbtPeer::ID, CpHotRbtPeer::CP_ID, CpHotRbtPeer::CP_CODE, CpHotRbtPeer::CP_NAME, CpHotRbtPeer::CHECK_TIME, CpHotRbtPeer::CONTENT_LANGUAGE, CpHotRbtPeer::RBT_INDEX, CpHotRbtPeer::LANGUAGE, CpHotRbtPeer::MUSIC_ID, CpHotRbtPeer::ORDER_TIMES, CpHotRbtPeer::PRICE, CpHotRbtPeer::PRICE_GROUP_ID, CpHotRbtPeer::RELATIVE_TIME, CpHotRbtPeer::SET_TIMES, CpHotRbtPeer::SINGER_NAME, CpHotRbtPeer::SINGER_NAME_LETTER, CpHotRbtPeer::SINGER_SEX, CpHotRbtPeer::STATUS, CpHotRbtPeer::TABLE_TYPE, CpHotRbtPeer::TONE_ADDRESS, CpHotRbtPeer::TONE_CODE, CpHotRbtPeer::TONE_CODE_LONG, CpHotRbtPeer::TONE_ID, CpHotRbtPeer::TONE_NAME, CpHotRbtPeer::TONE_NAME_LETTER, CpHotRbtPeer::TONE_PATH, CpHotRbtPeer::TONE_PRE_LISTEN_ADDRESS, CpHotRbtPeer::TONE_PRE_LISTEN_PATH, CpHotRbtPeer::TONE_VALID_DAY, CpHotRbtPeer::UPDATE_TIME, CpHotRbtPeer::UPLOAD_TIME, CpHotRbtPeer::UPLOAD_TYPE, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'cp_id', 'cp_code', 'cp_name', 'check_time', 'content_language', 'rbt_index', 'language', 'music_id', 'order_times', 'price', 'price_group_id', 'relative_time', 'set_times', 'singer_name', 'singer_name_letter', 'singer_sex', 'status', 'table_type', 'tone_address', 'tone_code', 'tone_code_long', 'tone_id', 'tone_name', 'tone_name_letter', 'tone_path', 'tone_pre_listen_address', 'tone_pre_listen_path', 'tone_valid_day', 'update_time', 'upload_time', 'upload_type', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CpId' => 1, 'CpCode' => 2, 'CpName' => 3, 'CheckTime' => 4, 'ContentLanguage' => 5, 'RbtIndex' => 6, 'Language' => 7, 'MusicId' => 8, 'OrderTimes' => 9, 'Price' => 10, 'PriceGroupId' => 11, 'RelativeTime' => 12, 'SetTimes' => 13, 'SingerName' => 14, 'SingerNameLetter' => 15, 'SingerSex' => 16, 'Status' => 17, 'TableType' => 18, 'ToneAddress' => 19, 'ToneCode' => 20, 'ToneCodeLong' => 21, 'ToneId' => 22, 'ToneName' => 23, 'ToneNameLetter' => 24, 'TonePath' => 25, 'TonePreListenAddress' => 26, 'TonePreListenPath' => 27, 'ToneValidDay' => 28, 'UpdateTime' => 29, 'UploadTime' => 30, 'UploadType' => 31, ),
		BasePeer::TYPE_COLNAME => array (CpHotRbtPeer::ID => 0, CpHotRbtPeer::CP_ID => 1, CpHotRbtPeer::CP_CODE => 2, CpHotRbtPeer::CP_NAME => 3, CpHotRbtPeer::CHECK_TIME => 4, CpHotRbtPeer::CONTENT_LANGUAGE => 5, CpHotRbtPeer::RBT_INDEX => 6, CpHotRbtPeer::LANGUAGE => 7, CpHotRbtPeer::MUSIC_ID => 8, CpHotRbtPeer::ORDER_TIMES => 9, CpHotRbtPeer::PRICE => 10, CpHotRbtPeer::PRICE_GROUP_ID => 11, CpHotRbtPeer::RELATIVE_TIME => 12, CpHotRbtPeer::SET_TIMES => 13, CpHotRbtPeer::SINGER_NAME => 14, CpHotRbtPeer::SINGER_NAME_LETTER => 15, CpHotRbtPeer::SINGER_SEX => 16, CpHotRbtPeer::STATUS => 17, CpHotRbtPeer::TABLE_TYPE => 18, CpHotRbtPeer::TONE_ADDRESS => 19, CpHotRbtPeer::TONE_CODE => 20, CpHotRbtPeer::TONE_CODE_LONG => 21, CpHotRbtPeer::TONE_ID => 22, CpHotRbtPeer::TONE_NAME => 23, CpHotRbtPeer::TONE_NAME_LETTER => 24, CpHotRbtPeer::TONE_PATH => 25, CpHotRbtPeer::TONE_PRE_LISTEN_ADDRESS => 26, CpHotRbtPeer::TONE_PRE_LISTEN_PATH => 27, CpHotRbtPeer::TONE_VALID_DAY => 28, CpHotRbtPeer::UPDATE_TIME => 29, CpHotRbtPeer::UPLOAD_TIME => 30, CpHotRbtPeer::UPLOAD_TYPE => 31, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'cp_id' => 1, 'cp_code' => 2, 'cp_name' => 3, 'check_time' => 4, 'content_language' => 5, 'rbt_index' => 6, 'language' => 7, 'music_id' => 8, 'order_times' => 9, 'price' => 10, 'price_group_id' => 11, 'relative_time' => 12, 'set_times' => 13, 'singer_name' => 14, 'singer_name_letter' => 15, 'singer_sex' => 16, 'status' => 17, 'table_type' => 18, 'tone_address' => 19, 'tone_code' => 20, 'tone_code_long' => 21, 'tone_id' => 22, 'tone_name' => 23, 'tone_name_letter' => 24, 'tone_path' => 25, 'tone_pre_listen_address' => 26, 'tone_pre_listen_path' => 27, 'tone_valid_day' => 28, 'update_time' => 29, 'upload_time' => 30, 'upload_type' => 31, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/CpHotRbtMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.CpHotRbtMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = CpHotRbtPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(CpHotRbtPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(CpHotRbtPeer::ID);

		$criteria->addSelectColumn(CpHotRbtPeer::CP_ID);

		$criteria->addSelectColumn(CpHotRbtPeer::CP_CODE);

		$criteria->addSelectColumn(CpHotRbtPeer::CP_NAME);

		$criteria->addSelectColumn(CpHotRbtPeer::CHECK_TIME);

		$criteria->addSelectColumn(CpHotRbtPeer::CONTENT_LANGUAGE);

		$criteria->addSelectColumn(CpHotRbtPeer::RBT_INDEX);

		$criteria->addSelectColumn(CpHotRbtPeer::LANGUAGE);

		$criteria->addSelectColumn(CpHotRbtPeer::MUSIC_ID);

		$criteria->addSelectColumn(CpHotRbtPeer::ORDER_TIMES);

		$criteria->addSelectColumn(CpHotRbtPeer::PRICE);

		$criteria->addSelectColumn(CpHotRbtPeer::PRICE_GROUP_ID);

		$criteria->addSelectColumn(CpHotRbtPeer::RELATIVE_TIME);

		$criteria->addSelectColumn(CpHotRbtPeer::SET_TIMES);

		$criteria->addSelectColumn(CpHotRbtPeer::SINGER_NAME);

		$criteria->addSelectColumn(CpHotRbtPeer::SINGER_NAME_LETTER);

		$criteria->addSelectColumn(CpHotRbtPeer::SINGER_SEX);

		$criteria->addSelectColumn(CpHotRbtPeer::STATUS);

		$criteria->addSelectColumn(CpHotRbtPeer::TABLE_TYPE);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_ADDRESS);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_CODE);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_CODE_LONG);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_ID);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_NAME);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_NAME_LETTER);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_PATH);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_PRE_LISTEN_ADDRESS);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_PRE_LISTEN_PATH);

		$criteria->addSelectColumn(CpHotRbtPeer::TONE_VALID_DAY);

		$criteria->addSelectColumn(CpHotRbtPeer::UPDATE_TIME);

		$criteria->addSelectColumn(CpHotRbtPeer::UPLOAD_TIME);

		$criteria->addSelectColumn(CpHotRbtPeer::UPLOAD_TYPE);

	}

	const COUNT = 'COUNT(cp_hot_rbt.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT cp_hot_rbt.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(CpHotRbtPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(CpHotRbtPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = CpHotRbtPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = CpHotRbtPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return CpHotRbtPeer::populateObjects(CpHotRbtPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			CpHotRbtPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = CpHotRbtPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return CpHotRbtPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(CpHotRbtPeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(CpHotRbtPeer::ID);
			$selectCriteria->add(CpHotRbtPeer::ID, $criteria->remove(CpHotRbtPeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(CpHotRbtPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(CpHotRbtPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof CpHotRbt) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(CpHotRbtPeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(CpHotRbt $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(CpHotRbtPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(CpHotRbtPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(CpHotRbtPeer::DATABASE_NAME, CpHotRbtPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = CpHotRbtPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(CpHotRbtPeer::DATABASE_NAME);

		$criteria->add(CpHotRbtPeer::ID, $pk);


		$v = CpHotRbtPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(CpHotRbtPeer::ID, $pks, Criteria::IN);
			$objs = CpHotRbtPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseCpHotRbtPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/CpHotRbtMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.CpHotRbtMapBuilder');
}
